// page.includeJs 引入 js

var page = require('webpage').create();

page.open('http://www.sample.com', function () {
    page.includeJs("https://cdn.css.net/libs/jquery/3.2.1/jquery.min.js", function () {
        page.evaluate(function () {
            $("button").click();
        });
        phantom.exit()
    });
});

//Make sure to put the exit statement within the page.includeJs or else it may exit prematurely before the javascript code is included.